#pragma once
#include "tpool/threadspool.h"
#include <our_header.h>
#define MAX_THREADS_NUM 8
#define MAX_QUEEN_CPTY 1024

typedef struct share_queen {
	pthread_mutex_t mutex; // 互斥
	pthread_cond_t cond;   // 同步
	int flag;			   // 标记检测
	int array_queen_caipacity; // 小火车共享队列容量
}SQueen;


typedef struct thread_data {
	SQueen *shareQueen; //共享数据包含锁,条件变量
	MYSQL *connect;		// 子线程线程独有
} tdata_t;

typedef struct threads_poll_s {
    int pthreads_sum;		// 线程数量
    int pthreads_rm_num;	// 还未初始化的数量
	pthread_t *pthread_tid; // 线程tid
    SQueen share_queen_data;
	tdata_t * thread_gets;
} TPoll;

int initThreadsPoll_h(int pthread_sum, int queen_caipacity);

int produceSocketFd_h(const SQItem *train);

int consumSocketFd_h(SQItem *train);

int exitThreadsPoll_h();

int startThreadsPoll_h(int threads_num,void *(*func)(void *));
